/*********************************************************
@file

@author J. Di Mattina

@brief test cases for the c-realize library utilities.

Tests the implentation of the c-realize utilities 
library.
*********************************************************/
/* standard library includes */
#include <assert.h>
#include <stdint.h>
#include <stdio.h>

/* local includes */
#include "Crz_Utils.h"

/*********************************************************
 main
*//**
@brief main program function

@return 0 on success
        errno otherwise.
**********************************************************/
int main()
{
    uint16_t u16 = 0x1776;
    uint32_t u32 = 0xdeadbeef;
    uint64_t u64 = 0xaabbccdd11223344ull;

    /* verify endian dependent swapping works */
    if (Crz_isBigEndian() == CRZ_FALSE)
    {
        assert(Crz_hton16(u16) == 0x7617);
        assert(Crz_hton32(u32) == 0xefbeadde);
        assert(Crz_hton64(u64) == 0x44332211ddccbbaa);
    }
    else
    {
        assert(Crz_hton16(u16) == 0x1776);
        assert(Crz_hton32(u32) == 0xdeadbeef);
        assert(Crz_hton64(u64) == 0xaabbccdd11223344);
    }

    /* do the round trip */
    assert(Crz_ntoh16(Crz_hton16(u16)) == u16);
    assert(Crz_ntoh32(Crz_hton32(u32)) == u32);
    assert(Crz_ntoh64(Crz_hton64(u64)) == u64);

    printf("Test Crz Utils: PASSED\n");
}
